import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { Switch, Route, Redirect } from 'react-router-dom';
import { Provider } from 'react-redux';
import {store, persistor} from './store/index';
import { ConfigProvider } from 'antd';
import zh_CN from 'antd/lib/locale-provider/zh_CN'; //国际化中文
import { ConnectedRouter } from 'connected-react-router';
import history from './store/history';
import Home from './routes/Home/index';
import Mine from './routes/Mine/index';
import Profile from './routes/Profile/index';
import './assets/css/common.less';
import Tabs from './components/Tabs';
import Login from './routes/Login';
import Register from './routes/Register';
import Detail from './routes/Detail';
import Cart from './routes/Cart';
import { PersistGate } from 'redux-persist/integration/react';

ReactDOM.render(
  <Provider store={store}>
    <PersistGate loading={null} persistor={persistor}>
      <ConnectedRouter history={history}>
        <ConfigProvider locale={zh_CN}>
          <main className="main-container">
            <Switch>
              <Route path="/" exact component={Home} />
              <Route path="/mine" component={Cart} />
              <Route path="/profile" component={Profile} />
              <Route path="/login" component={Login} />
              <Route path="/register" component={Register} />
              <Route path="/detail/:id" component={Detail} />
              <Route path="/cart" component={Cart} />
            </Switch>
          </main>
          <Tabs />
        </ConfigProvider>
      </ConnectedRouter>
    </PersistGate>
  </Provider>,
  document.getElementById('root')
);
